<template>
  <div class="wpwork-common-layout">
    <div class="wpwork-common-layout-center">
      <el-row class="wpwork-common-search-box" :gutter="16">
        <el-form @submit.native.prevent>
          <el-col :span="6">
            <el-form-item label="调度员英文名">
              <el-input v-model="query.name" placeholder="调度员英文名" clearable
                @keyup.enter.native="search()" />
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="开始时间">
              <el-time-picker v-model="query.startTime" placeholder="选择开始时间">
              </el-time-picker>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="结束时间">
              <el-time-picker v-model="query.endTime" placeholder="选择结束时间">
              </el-time-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div class="wpwork-common-layout-main wpwork-flex-main">
        <wpwork-table v-loading="listLoading" :data="list">
          <el-table-column type="selection" width="55" />
          <el-table-column prop="value1" label="调度员" show-overflow-tooltip />
          <el-table-column prop="value2" label="模块名称" show-overflow-tooltip />
          <el-table-column prop="value3" label="操作名" show-overflow-tooltip />
          <el-table-column prop="value4" label="时间" show-overflow-tooltip />
          <el-table-column prop="value5" label="描述" show-overflow-tooltip />
        </wpwork-table>
        <pagination :total="total" :page.sync="listQuery.currentPage"
          :limit.sync="listQuery.pageSize" @pagination="initData" />
      </div>
    </div>
    <Form v-if="formVisible" ref="Form" @refreshDataList="initData" />
  </div>
</template>

<script>
import mixin from '@/mixins/generator/index'
import request from "@/utils/request";
import Form from "./Form";
export default {
  name: 'homeworkManagement',
  mixins: [mixin],
  components: { Form },

  data() {
    return {
      list: [],
      formVisible: false,
      query: { keyword: '', pageSize: 20, currentPage: 1 },
    }
  },
  mounted() {
    this.initData()
  },
  methods: {

    openDetails() {
      this.formVisible = true;
      this.$nextTick(() => {
        this.$refs.Form.init();
      });
    },
    initData() {
      this.list = [{
        value1: "张三",
        value2: "修改密码",
        value3: "修改密码",
        value4: "2025-08-27 09:05:05",
        value5: "调度员：张三修改密码成功",
      }, {
        value1: "李四",
        value2: "群组管理",
        value3: "群组管理",
        value4: "2025-08-26 11:03:25",
        value5: "调度员：张三群组管理成功",
      }]
      // request({
      //   url: `/api/example/WorkResources/List`,
      //   method: "post",
      //   query: this.query
      // }).then((res) => {
      //   console.log("🚀 ~ :122 ~ initData ~ res:", res)
      //   this.list = res.data.list;
      //   this.list.forEach(item => {
      //     item.creatorTime = this.formatLocalDateTime(item.creatorTime);
      //   })
      //   console.log("🚀 ~ :152 ~ initData ~ this.list:", this.list)
      // });
    },
    formatLocalDateTime(arr) {
      const [year, month, day, hour, minute, second, nano] = arr;
      const millisecond = Math.floor(nano / 1000000);
      const d = new Date(year, month - 1, day, hour, minute, second, millisecond);

      const pad = (n) => n.toString().padStart(2, '0');
      return `${year}-${pad(month)}-${pad(day)} ${pad(hour)}:${pad(minute)}:${pad(second)}.${Math.floor(millisecond)}`;
    },
    reset() {
      this.query = { keyword: '', pageSize: 20, currentPage: 1 }
    },
    search() {

    },
  }
}
</script>